#!/usr/bin/env python3

import rospy
from std_msgs.msg import String


def callback(data):
    rospy.loginfo('I heard %s', data.data)

    if rospy.get_param('~exit_after_receive', False):
        rospy.signal_shutdown(
            'Requested to exit after message received. Exiting now.')


def listener():
    rospy.init_node('listener')

    rospy.Subscriber('babble', String, callback)

    rospy.spin()

if __name__ == '__main__':
    listener()
